﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OGS.Contracts;
using OGS.Utility;

namespace OGS.Web.Controllers.Admin
{
    /// <summary>
    /// This is the base controller class for writting common methods and attributes
    /// </summary>
    public class AdminBaseController : Controller
    {
        /// <summary>
        /// Get Search Attributes from query string
        /// </summary>
        /// <returns></returns>
        public SearchAttributes GetSearchAttributesFromQuesryString()
        {
            SearchAttributes SearchAttributes = new SearchAttributes();
            SearchAttributes.CurrentPageNumber = Helper.GetQueryStringValueInt("page");
            SearchAttributes.CurrentPageNumber = SearchAttributes.CurrentPageNumber == 0 ? 1 : SearchAttributes.CurrentPageNumber;
            SearchAttributes.SortColumnIndex = Helper.GetQueryStringValueInt("SortColumnIndex");
            SearchAttributes.SortDirection = (SortDirection)Helper.GetQueryStringValueInt("SortDirection");
            SearchAttributes.RecordsPerPage = Settings.RecordsPerPage;

            return SearchAttributes;
        }
    }
}
